﻿<%@ Page Title="" Language="C#" MasterPageFile="~/AdminCP/admincp.Master" AutoEventWireup="true"
    CodeBehind="ListOrders.aspx.cs" Inherits="VINETLIFE.AdminCP.ListOrders" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script type="text/javascript">
        function checkOrderNull() {
            var txtMaHoaDon = $('[id$=txtMaHoaDon]');
            if (txtMaHoaDon.val().trim() == '') {
                alert('Vui lòng nhập mã hóa đơn');
                txtMaHoaDon.focus();
                return false;
            }
            else {
                return true;
            }
        }

    </script>
    <style type="text/css">
        label {
        width:150px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
            <h1 class="title">Danh sách đơn hàng</h1>
            <div class="search">
                <fieldset class="fieldset">
                    <legend>Lọc hiển thị</legend>
                    <table width="100%">
                        <tr>
                            <td style="width:500px;">
                                <label>
                                    Sắp xếp theo</label>
                                <asp:DropDownList ID="ddlSort" runat="server" CssClass="dropDown"
                                    Width="200px">
                                    <asp:ListItem Text="Mới nhất" Value="1" />
                                    <asp:ListItem Text="Cũ nhất" Value="2" />
                                </asp:DropDownList>

                            </td>
                            <td>
                                <label>
                                    Trạng thái xử lý</label>
                                <asp:DropDownList ID="ddlTransactionStatus" runat="server" CssClass="ddlTransactionStatus" Width="150px" AppendDataBoundItems="true" DataTextField="TransactionStatus" DataValueField="TransactionStatusCode">
                                    <asp:ListItem Value="" Text="Tất cả" />
                                </asp:DropDownList>
                            </td>
                        </tr>
                        <tr>
                             <td style="width:500px;">
                                <label>
                                    Phương thức
                                </label>
                                <asp:DropDownList ID="ddlPaymentMethod" runat="server" CssClass="dropDown" DataTextField="PaymentText" DataValueField="PaymentCode" AppendDataBoundItems="true" Width="200px" >
                                    <asp:ListItem Value="" Text="Tất cả" />
                                </asp:DropDownList>
                            </td>
                            <td>
                                <label>
                                    Khách hàng
                                </label>
                                <asp:DropDownList ID="ddlCustomer" runat="server" CssClass="dropDown" DataTextField="UserName" DataValueField="Id" AppendDataBoundItems="true" Width="150px"
                                    AutoPostBack="True">
                                    <asp:ListItem Value="0" Text="Tất cả" />
                                </asp:DropDownList>
                            </td>
                          
                        </tr>
                        <tr>
                            <td style="width:500px;">
                                <label>
                                    Trạng thái đơn hàng
                                </label>
                                <asp:DropDownList ID="ddlSystemStatus"  Width="200px" runat="server" CssClass="dropDown" DataTextField="SystemStatusText" DataValueField="SystemStatus" AppendDataBoundItems="true">
                                    <asp:ListItem Value="" Text="Tất cả" />
                                </asp:DropDownList>
                            </td>
                              <td>
                                <asp:Button ID="btnFilter" Text="Lọc" runat="server" CssClass="button-gg-green" OnClick="btnFilter_Click" />
                            </td>
                        </tr>
                    </table>
                    <table>
                        <tr>
                            <td>Tìm theo mã hóa đơn</td>
                            <td>
                                <asp:TextBox runat="server" ID="txtMaHoaDon" placeholder="Nhập mã hóa đơn"></asp:TextBox>
                                <asp:Button runat="server" ID="btnSearch" Text="Tìm kiếm" CssClass="button-gg-green" OnClick="btnSearch_Click" OnClientClick="return checkOrderNull();" />
                                <asp:Button runat="server" ID="btnShowAll" Text="Hiện toàn bộ" CssClass="button-gg-green" OnClick="btnShowAll_Click" />
                            </td>
                        </tr>
                    </table>
                </fieldset>
            </div>
            <div id="gridview">
                <asp:GridView ID="grvOrders" runat="server" CssClass="tstyle1" Width="100%" AutoGenerateColumns="False" OnRowDataBound="grvOrders_RowDataBound"
                    AllowPaging="True" OnRowCommand="grvOrders_RowCommand" OnPageIndexChanging="grvOrders_PageIndexChanging"
                    PageSize="10" EmptyDataText="Dữ liệu trống !">
                    <Columns>
                        <asp:TemplateField ItemStyle-Width="25px" ItemStyle-HorizontalAlign="Center">
                            <HeaderTemplate>
                                <input type="checkbox" name="checkAll" id="checkAll" />
                            </HeaderTemplate>
                            <ItemTemplate>
                                <input type="checkbox" name="checkEach" id="checkEach" />
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="#" ItemStyle-Width="25px" ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <%# Container.DataItemIndex+1 %>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField ItemStyle-Width="450px" HeaderText="Thông tin khách hàng">
                            <ItemTemplate>
                                <table class="item-price-table" style="box-shadow: none;">
                                    <asp:Repeater runat="server" ID="rptCustomers">
                                        <ItemTemplate>
                                            <tr>
                                                <td class="item-l-td">Username
                                                </td>
                                                <td>
                                                    <span>
                                                        <%#(bool.Parse(Eval("IsVangLai").ToString()))?"Khách vãng lai":Eval("Username") %>
                                                    </span>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="item-l-td">Họ tên
                                                </td>
                                                <td>
                                                    <span>
                                                        <%#Eval("FullName") %>
                                                    </span>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="item-l-td">Địa chỉ
                                                </td>
                                                <td>
                                                    <%#Eval("Address") %>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="item-l-td">Điện thoại
                                                </td>
                                                <td>
                                                    <%#Eval("Phone") %>
                                                </td>
                                            </tr>
                                            <td class="item-l-td">Email
                                            </td>
                                            <td>
                                                <%#Eval("Email") %>
                                            </td>
                                            </tr>
                                        </ItemTemplate>
                                    </asp:Repeater>
                                     <tr <%#(bool)(Eval("PaymentMethod").ToString().ToLower().Equals("home"))?"style='display:table-row;'":"style='display:none;'" %>>
                                        <td class="item-l-td">Địa chỉ giao hàng
                                        </td>
                                        <td>
                                            <%#Eval("Address") %>
                                        </td>
                                    </tr>
                                </table>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField ItemStyle-Width="450px" HeaderText="Thông tin đơn hàng">
                            <ItemTemplate>
                                <table class="item-price-table">
                                    <tr>
                                        <td class="item-l-td">Mã đơn hàng
                                        </td>
                                        <td>
                                            <%#Eval("InvoiceNumber") %>
                                        </td>
                                    </tr>
                                     <tr>
                                        <td class="item-l-td">Trạng thái đơn hàng
                                        </td>
                                        <td>
                                            <%#Eval("SystemStatusText") %>
                                        </td>
                                    </tr>
                                     <tr>
                                        <td class="item-l-td">Trạng thái xử lý
                                        </td>
                                        <td>
                                            <%#Eval("TransactionStatusText") %>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="item-l-td">Sản phẩm
                                        </td>
                                        <td>
                                            <%#ReturnItems(Eval("Id"))%>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="item-l-td">Ngày gửi
                                        </td>
                                        <td>
                                            <%#Eval("CreateDate","{0:dd/MM/yyyy HH:mm tt}") %>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="item-l-td">Ngày yêu cầu
                                        </td>
                                        <td>
                                            <%#Eval("CreateDate","{0:dd/MM/yyyy HH:mm tt}") %>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="item-l-td">Phương thức thanh toán
                                        </td>
                                        <td>
                                            <%#Eval("PaymentText") %>
                                        </td>
                                    </tr>
                                    <tr <%#(bool.Parse(Eval("IsUseVirtualAccount").ToString()))?"style='display:table-row;'":"style='display:none;'" %>>
                                        <td class="item-l-td">Sử dụng Ví Vinetlife
                                        </td>
                                        <td>
                                           <asp:CheckBox Checked='<%#Eval("IsUseVirtualAccount") %>' Enabled="false" runat="server" ID="chkisUseVinetlifeAccount" />
                                        </td>
                                    </tr>
                                    <tr <%#(bool.Parse(Eval("IsUseVirtualAccount").ToString()))?"style='display:table-row;'":"style='display:none;'" %>>
                                        <td class="item-l-td">Mã tài khoản
                                        </td>
                                        <td>
                                            <%#Eval("AccountCode") %>
                                        </td>
                                    </tr>
                                    <tr <%#(bool)(Eval("PaymentMethod").ToString().ToLower().Equals("momo") || Eval("PaymentMethod").ToString().ToLower().Equals("mbplus"))?"style='display:table-row;'":"style='display:none;'" %>>
                                        <td class="item-l-td">TransactionId
                                        </td>
                                        <td>
                                            <%#Eval("TransactionId") %>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="item-l-td">Tổng tiền
                                        </td>
                                        <td>
                                            <span style="color: red;"><%#Eval("GrandTotal","{0:0,#}")%> đ</span>
                                        </td>
                                    </tr>
                                </table>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Thao tác" ItemStyle-Width="125px">
                            <ItemTemplate>
                                <div class="orders-command">
                                    <div class="orders-row">
                                        <asp:Button runat="server" ID="btnHide" Text="Ẩn đơn hàng" Width="100%" CommandName="HideOrder" CommandArgument='<%#Eval("Id")%>' CssClass="button-gg-green" OnClientClick="return confirm('Xác nhận ẩn đơn hàng này? Nhấn OK để ẩn!')" />
                                    </div>
                                    <div class="orders-row">
                                        <asp:Button runat="server" ID="btnDeleteOrder" Text="Xóa đơn hàng" Width="100%" CommandName="DeleteOrder" CommandArgument='<%#Eval("Id")%>' CssClass="button-gg-green" OnClientClick="return confirm('Xác nhận xóa đơn hàng này? Nhấn OK để xóa!')" />
                                    </div>
                                    <div class="orders-row">
                                        <asp:Button runat="server" ID="btnDetail" Text="Chi tiết đơn hàng" Width="100%" CommandName="Detail" CommandArgument='<%#Eval("Id")%>' CssClass="button-gg-green" />
                                    </div>
                                    <div class="orders-row">
                                        <asp:Button runat="server" ID="btnCancelOrder" Text="Hủy đơn hàng" Width="100%" CommandName="CancelOrder" CommandArgument='<%#Eval("Id")%>' CssClass="button-gg-green" OnClientClick="return confirm('Xác nhận hủy đơn hàng này? Nhấn OK để hủy!')"  />
                                    </div>
                                    <div class="orders-row">
                                        <asp:Button runat="server" ID="btnFinish" Text="Xử lý hoàn tất" Width="100%" CommandName="FinishOrder" CommandArgument='<%#Eval("Id")%>' CssClass="button-gg-green" />
                                    </div>
                                </div>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                </asp:GridView>
                <asp:UpdateProgress ID="UpdateProgress1" runat="server">
                    <ProgressTemplate>
                        <img src="../../Images/ajax-loader.gif" alt="Loadding" style="position: absolute; top: 50%; left: 50%; z-index: 1000" />
                    </ProgressTemplate>
                </asp:UpdateProgress>
            </div>
            <div style="margin: 10px 0px">
                <label style="width: auto;">
                    Số dòng hiển thị trên 1 trang :
                </label>
                <asp:DropDownList runat="server" ID="dropPageSize" CssClass="dropdown" AutoPostBack="true"
                    OnSelectedIndexChanged="dropCountRow_SelectedIndexChanged">
                    <asp:ListItem Text=" 10 " Value="10" Selected="True" />
                    <asp:ListItem Text=" 20 " Value="20" />
                    <asp:ListItem Text=" 30 " Value="30" />
                    <asp:ListItem Text=" 50 " Value="50" />
                    <asp:ListItem Text=" 100 " Value="100" />
                </asp:DropDownList>
            </div>
            <div style="margin-top: 10px">
                <asp:Literal ID="lbThongBao" runat="server" />
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
